package com.datawin.taotaocheche.comm;


import com.datawin.taotaocheche.base.BaseBean;
import com.datawin.taotaocheche.base.BaseResp;
import com.datawin.taotaocheche.bean.AppVersion;
import com.datawin.taotaocheche.bean.BannerInfo;
import com.datawin.taotaocheche.bean.BillInfo;
import com.datawin.taotaocheche.bean.CityInfo;
import com.datawin.taotaocheche.bean.ClueInfo;
import com.datawin.taotaocheche.bean.CustomInfo;
import com.datawin.taotaocheche.bean.MsgInfo;
import com.datawin.taotaocheche.bean.RechargeSettingInfo;
import com.datawin.taotaocheche.bean.UserInfo;
import com.datawin.taotaocheche.pay.WxBean;

import java.util.List;
import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Query;
import retrofit2.http.Url;
import rx.Observable;

/**
 * Created by chenjian on 16/6/12.
 */
public interface ApiService {
    /**
     * test
     */
    @POST
    @FormUrlEncoded
    Observable<BaseResp<Object>> test(@Url String url);


    // *************************************************************************
    // TODO  控制器 user 用户信息


    /**
     * 检测更新(ok)
     *
     * @return
     */
    @POST("Common/ShopAppVersion")
    @FormUrlEncoded
    Observable<BaseResp<AppVersion>> getAppVersion();



    /**
     * 登录
     *
     * @return
     */
    @POST("common/loginCheck")
    @FormUrlEncoded
    Observable<BaseResp<UserInfo>> loginCheck(@Field("mobile") String mobile,
                                              @Field("password") String password,
                                              @Field("alias") String alias,
                                              @Field("loginType") String loginType //android or  Ios
    );

    /**
     * 注册
     *
     * @return
     */
    @POST("common/regCheck")
    @FormUrlEncoded
    Observable<BaseResp<UserInfo>> regCheck(@Field("mobile") String mobile,
                                            @Field("password") String password,
                                            @Field("vaidCode") String vaidCode,
                                            @Field("alias") String alias

    );


    /**
     * 获取验证码
     *
     * @return
     */
    @GET("common/mobileSms")
    Observable<BaseResp<Object>> mobileSms(@Query("mobile") String mobile,
                                           @Query("type") Integer password//1 注册 2 忘记密码
    );


    /**
     * 忘记密码
     *
     * @return
     */
    @GET("common/forgetPswCheck")
    Observable<BaseResp<Object>> forgetPswCheck(@Query("mobile") String mobile,
                                                @Query("password") String password,
                                                @Query("vaidCode") String vaidCode
    );




    /**
     * 个人中心认证
     *
     * @return
     */
    @Multipart
    @POST("cus/user/userCheck2")
    Observable<BaseResp<Object>> userCheck2(@PartMap Map<String, RequestBody> map,
                                            @Part List<MultipartBody.Part> parts
    );


    /**
     * 注册认证
     *
     * @return
     */
    @Multipart
    @POST("cus/user/userCheck")
    Observable<BaseResp<Object>> userCheck(@PartMap Map<String, RequestBody> map,
                                           @Part List<MultipartBody.Part> parts
    );


    /**
     * 城市接口  去哪儿去是三级， 我爱融和二手车是一级
     *
     * @return
     */
    @GET("common/businessCircleData2")
    Observable<BaseResp<List<CityInfo>>> businessCircleData(
    );



    /**
     * 充值优惠规则
     *
     * @return
     */
    @POST("cus/user/rechargePage")
    @FormUrlEncoded
    Observable<BaseResp<List<RechargeSettingInfo>>> rechargePage(@Field("userCode") String userCode
    );


    /**
     * 创建订单
     *
     * @return
     */
    @POST("cus/pay/createStudentOrder")
    @FormUrlEncoded
    Observable<BaseResp<Object>> createStudentOrder(@Field("userCode") String userCode,
                                                    @Field("studentCode") String studentCode,
                                                    @Field("orderAmount") String orderAmount
    );

    /**
     * 创建充值订单
     *
     * @return
     */
    @POST("cus/pay/rechargeConfirm")
    @FormUrlEncoded
    Observable<BaseResp<String>> rechargeConfirm(@Field("userCode") String userCode,
                                                 @Field("rechargeSettingId") String rechargeSettingId,
                                                 @Field("payMethod") String payMethod //alipay    wxpay
    );


    /**
     * 创建充值订单
     *
     * @return
     */
    @POST("cus/pay/rechargeConfirm")
    @FormUrlEncoded
    Observable<BaseResp<WxBean>> wexiConfirm(@Field("userCode") String userCode,
                                             @Field("rechargeSettingId") String rechargeSettingId,
                                             @Field("payMethod") String payMethod //alipay    wxpay
    );

    /**
     * 修改会员信息
     *
     * @return
     */
    @POST("cus/cus/user/userInfo")
    @FormUrlEncoded
    Observable<BaseResp<Object>> userInfo(@Field("user") String user
    );

    /**
     * 修改密码
     *
     * @return
     */
    @POST("cus/user/resetPsw")
    @FormUrlEncoded
    Observable<BaseResp<Object>> resetPsw(@Field("userCode") String userCode,
                                          @Field("oldPsw") String oldPsw,
                                          @Field("newPsw") String newPsw
    );


    /**
     * 未知
     *
     * @return
     */
    @POST("cus/user/userPage")
    @FormUrlEncoded
    Observable<BaseResp<UserInfo>> userPage(@Field("userCode") String userCode
    );



    /**
     * 我购买的学生信息
     *
     * @return
     */
    @POST("cus/user/myStudentList")
    @FormUrlEncoded
    Observable<BaseResp<BaseBean<List<ClueInfo>>>> myStudentList(@Field("userCode") String userCode,
                                                                 @Field("pageNum") Integer pageNum,
                                                                 @Field("pagesize") Integer pagesize
    );

    /**
     * 我的收藏
     *
     * @return
     */
    @POST("cus/user/myCollectionList")
    @FormUrlEncoded
    Observable<BaseResp<BaseBean<List<ClueInfo>>>> myCollectionList(@Field("userCode") String userCode,
                                                                    @Field("pageNum") Integer pageNum,
                                                                    @Field("pagesize") Integer pagesize
    );

    /**
     * 我的收藏
     *
     * @return
     */
    @POST("cus/user/delMyCollection")
    @FormUrlEncoded
    Observable<BaseResp<Object>> delMyCollection(@Field("userCode") String userCode,
                                                 @Field("uid") String uid
    );


    /**
     * 添加收藏
     *
     * @return
     */
    @POST("cus/user/addMyCollection")
    @FormUrlEncoded
    Observable<BaseResp<CustomInfo>> addMyCollection(@Field("userCode") String userCode,
                                                     @Field("studentCode") String studentCode
    );

    /**
     * 添加建议
     *
     * @return
     */
    @POST("cus/user/addSuggest")
    @FormUrlEncoded
    Observable<BaseResp<Object>> addSuggest(@Field("userCode") String userCode,
                                            @Field("content") String content
    );


    /**
     * 消息记录
     *
     * @return
     */
    @POST("cus/user/messagePage")
    @FormUrlEncoded
    Observable<BaseResp<List<MsgInfo>>> messagePage(@Field("userCode") String userCode
    );

    /**
     * 余额记录
     *
     * @return
     */
    @POST("cus/user/financeRecordPage")
    @FormUrlEncoded
    Observable<BaseResp<List<BillInfo>>> financeRecordPage(@Field("userCode") String userCode
    );


    /**
     * 个人信息
     *
     * @return
     */
    @POST("cus/user/userInfoPage")
    @FormUrlEncoded
    Observable<BaseResp<List<UserInfo>>> userInfoPage(@Field("userCode") String userCode
    );


    /**
     * 个人信息
     *
     * @return
     */
    @POST("cus/clue/userList3")
    @FormUrlEncoded
    Observable<BaseResp<BaseBean<List<ClueInfo>>>> userList(@Field("userCode") String userCode,
                                                            @Field("pageNum") Integer pageNum,
                                                            @Field("pageSize") Integer pagesize,
                                                            @Field("cityIds") String cityIds,//城市
                                                            @Field("carName")  String carName,//
                                                            @Field("year") Integer year,//贷款期限   0：不限    1.3个月   2.6个月   3.12个月   4.24个月   5.36个月
                                                            @Field("road") Integer road //
    );


    /**
     * 线索详情
     *
     * @return
     */
    @POST("cus/clue/studentInfo")
    @FormUrlEncoded
    Observable<BaseResp<CustomInfo>> studentInfo(@Field("userCode") String userCode,
                                                 @Field("studentCode") String studentCode,
                                                 @Field("useable") String useable
    );


    /**
     * 首页轮播图
     *
     * @return
     */
    @POST("cus/clue/bannerList")
    @FormUrlEncoded
    Observable<BaseResp<BaseBean<List<BannerInfo>>>> bannerList(@Field("pageNum") Integer pageNum,
                                                                @Field("pagesize") Integer pagesize

    );


    /**
     * 发起退款
     *
     * @return
     */
    @POST("cus/user/refund")
    @FormUrlEncoded
    Observable<BaseResp<Object>> refund(@Field("userCode") String userCode

    );
    /**
     * 上传头像
     *
     * @return
     */
    @Multipart
    @POST("cus/user/updatePhoto")
    Observable<BaseResp<Object>> updatePhoto(@PartMap Map<String, RequestBody> map,
                                             @Part List<MultipartBody.Part> parts
    );

    /**
     * 我购买的学生信息
     *
     * @return
     */
    @POST("cus/user/myStudentList3")
    @FormUrlEncoded
    Observable<BaseResp<BaseBean<List<ClueInfo>>>> myStudentList3(@Field("userCode") String userCode,
                                                                  @Field("startTime") String startTime,
                                                                  @Field("endTime") String endTime,
                                                                  @Field("customerType") String customerType
    );

// ===================add data 2018-07-23===================
    /**
     * 申请线索批次
     *
     * @param applyUser
     * @param applyCount
     * @return
     */
    @POST("cus/apply/add")
    @FormUrlEncoded
    Observable<BaseResp<Object>> applyAdd(@Field("applyUser") String applyUser,
                                          @Field("applyCount") String applyCount);

    /**
     * 查看批次
     * @param userCode
     * @param pageSize
     * @param pageNum
     * @return
     */
    @POST("cus/cmBtachInfo/getBatchInfoByUserCode")
    @FormUrlEncoded
    Observable<BaseResp<BaseBean<List<ClueInfo>>>> getBatchInfoByUserId(@Field("userCode") String userCode,
                                                                        @Field("pageSize") Integer pageSize,
                                                                        @Field("pageNum") Integer pageNum,
                                                                        @Field("startTime") String startTime,
                                                                        @Field("endTime") String endTime,
                                                                        @Field("consumerType") String customerType);


}
